// import React, { Component } from "react";

// export default class App extends Component {
//   state = {
//     counter: 100,
//   };
//   render() {
//     return (
//       <div>
//         <h1>当前计数为： {this.state.counter}</h1>
//         <button onClick={() => this.increment()}>+</button>
//       </div>
//     );
//   }
//   increment() {
//     this.setState((state) => ({ counter: (state.counter += 1) }));
//   }
// }

import React, { useState } from "react";

export default function App() {
  const [counter, setCounter] = useState(100);
  return (
    <div>
      <h1>{counter}</h1>
      <button onClick={() => setCounter(counter + 1)}>+</button>
    </div>
  );
}
